package com.cyb.binojbackendquestionservice.controller.inner;

import com.cyb.binojbackendcommon.common.BaseResponse;
import com.cyb.binojbackendcommon.common.ResultUtils;
import com.cyb.binojbackendmodel.model.codesandbox.JudgeInfo;
import com.cyb.binojbackendmodel.model.entity.Question;
import com.cyb.binojbackendmodel.model.entity.QuestionSubmit;
import com.cyb.binojbackendquestionservice.service.QuestionService;
import com.cyb.binojbackendquestionservice.service.QuestionSubmitService;
import com.cyb.binojbackendserviceclient.service.QuestionFeginClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 该服务仅内部服务，不允许外部访问
 */
@RestController()
@RequestMapping("/inner")
public class QuestionInnerController implements QuestionFeginClient {


    @Resource
    private QuestionService questionService;
    @Resource
    private QuestionSubmitService questionSubmitService;
    @Override
    @GetMapping("/get/id")
    public Question getQuestionById(@RequestParam("questionId") long questionId){
        return questionService.getById(questionId);
    };

    @Override
    @GetMapping("/question_submit/get/id")
    public QuestionSubmit getQuestionSubmitById(@RequestParam("questionSubmitId")long questionSubmitId){
        return questionSubmitService.getById(questionSubmitId);
    };

    @Override
    @PostMapping("/question_submit/update")
    public boolean updateQuestionSubmitById(@RequestBody QuestionSubmit questionSubmit){
        return questionSubmitService.updateById(questionSubmit);
    };

    @PostMapping("/question_submit/modify")
    public boolean modifyCommit(long questionId, JudgeInfo judgeInfo){
        return questionService.modifyCommit(questionId, judgeInfo);
    }
}
